package com.mzpai.product.service.impl;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mzpai.product.mapper.BoardReportMapper;
import com.mzpai.product.model.BoardReport;
import com.mzpai.product.service.BoardReportService;
import com.mzpai.service.impl.BaseServiceImpl;
import com.mzpai.util.DateUtil;
/**
 *
 * <b>运营看板统计 | Service</b><br>
 *
 * yanglijun 2021-03-19 10:51:18
 * 
 *  @version 1.0.0
 *
 */
@Service
public class BoardReportServiceImpl extends BaseServiceImpl<BoardReport> implements BoardReportService {

	Logger logger = LoggerFactory.getLogger(BoardReport.class);

	@Autowired 
	private BoardReportMapper mapper;
	
	/**
     * 根据storeId，查询流量信息
     * @param id
     * @return
     */
	@Override
    public BoardReport queryFlowReport(String storeId) {
		try{
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("storeId", storeId);
			map.put("flowDate", DateUtil.formatDate(new Date()));
			BoardReport info = mapper.queryFlowReport(map);
			if(info == null) {
				BoardReport o = new BoardReport();
				o.setCount(0D);
				return o;
			}
			return info;
		} catch(Exception e) {
			BoardReport o = new BoardReport();
			o.setCount(0D);
			return o;
		}
	}
    
    
    
    /**
     * 根据storeId，查询营业额信息
     * @param id
     * @return
     */
	@Override
    public BoardReport queryOrderAmounReport(String storeId)  {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("storeId", storeId);
		map.put("createDate", DateUtil.formatDate(new Date()));
		return mapper.queryOrderAmounReport(map);
	}
    
    
    /**
     * 根据storeId，查询已支付订单数量
     * @param id
     * @return
     */
	@Override
    public BoardReport queryOrderReport(String storeId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("storeId", storeId);
		map.put("createDate", DateUtil.formatDate(new Date()));
		map.put("paid", 1);
		return mapper.queryOrderReport(map);
	}
}